//
//  ReplyCellFrameLayout.m
//  sensen_ios
//
//  Created by boye_mac1 on 16/4/1.
//  Copyright © 2016年 pro. All rights reserved.
//

#import "ReplyCellFrameLayout.h"
#import "ZKTextImgReplaceHandle.h"
@implementation ReplyCellFrameLayout

- (void)setModel:(ReplyModel *)model{
    _model = model;
    
    // 布局
    // 1.头像
    CGFloat iconX = 10;
    CGFloat iconY = 5;
    CGFloat iconW = 30;
    CGFloat iconH = iconW;
    _iconRect = CGRectMake(iconX, iconY, iconW, iconH);
    
    // 2.昵称
    CGFloat nickX = CGRectGetMaxX(_iconRect) + 5;
    CGFloat nickY = CGRectGetMinY(_iconRect);
    CGFloat nickW = [model.nickname getSizeOfString:15].width;
    CGFloat nickH = 15;
    nickW = (nickW < 200) ? nickW : 200;
    _nickRect = CGRectMake(nickX, nickY, nickW, nickH);
    _nickRect2 = CGRectMake(nickX, nickY, [@"禁言用户" getSizeOfString:15].width, nickH);
    
    //楼主
    CGFloat louX = CGRectGetMaxX(_nickRect) + 5;
    CGFloat louY = CGRectGetMinY(_iconRect);
    CGFloat louW = 30;
    CGFloat louH = 15;
    _louImageRect = CGRectMake(louX, louY, louW, louH);
    
    // 3.评论创建时间
    CGFloat timeX = CGRectGetMinX(_nickRect);
    CGFloat timeY = CGRectGetMaxY(_nickRect);
    CGFloat timeW = [model.dateline_show getSizeOfString:12].width;
    CGFloat timeH = iconH - nickH;
    _createTimeRect = CGRectMake(timeX, timeY, timeW, timeH);
    
    //回复内容
    CGFloat contentX = CGRectGetMinX(_createTimeRect);
    CGFloat contentY = CGRectGetMaxY(_createTimeRect) + 5;
    CGFloat contentW = SCREEN_WIDTH - contentX - 10;
//    CGFloat contentH = [_model.comment getBoundingRectOfStringSize:CGSizeMake(contentW, 10000) font:13].size.height;
    CGFloat contentH = [ZKTextImgReplaceHandle getImgTextHeightWithText:_model.comment regex:nil size:CGSizeMake(contentW, 10000) fontSize:15];
    contentH = (contentH < 20) ? 20 : contentH;
    _replyRect = CGRectMake(contentX, contentY, contentW, contentH);
    
    //cell尺寸
    CGFloat x = 0;
    CGFloat y = 0;
    CGFloat h = CGRectGetMaxY(_replyRect) + 15;
    CGFloat w = SCREEN_WIDTH;
    _cellRect = CGRectMake(x, y, w, h);
}
@end
